package com.gameley.dmgtpf.kernel.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gameley.dmgtpf.common.core.aspect.MyDoneTime;
import com.gameley.dmgtpf.common.utils.Result;
import com.gameley.dmgtpf.kernel.entity.PsndatasEntity;
import com.gameley.dmgtpf.kernel.service.PsndatasService;

/**
 * 
 **
 * @qualiFild PsndatasController.java<br>
 * @author：LiBencheng<br>
 * @date Created on 2021年7月28日<br>
 * @version 1.0<br>
 */
@RestController
@RequestMapping("kernel/psndatas")
public class PsndatasController
{
    @Autowired
    private PsndatasService psndatasService;
    
    /**
     * 列表
     */
    @MyDoneTime(param = "PsndatasController.list")
    @RequestMapping("/list")
    @RequiresPermissions("dmpf:psndatas:list")
    public Result list(@RequestParam Map<String, Object> params)
    {
        
        QueryWrapper<PsndatasEntity> wrapper = new QueryWrapper<PsndatasEntity>();
        wrapper.allEq(params);
        
        List<PsndatasEntity> list = psndatasService.list(wrapper);
        
        return Result.ok().put("page", list);
        
    }
    
    /**
     * 信息
     */
    @MyDoneTime(param = "PsndatasController.info")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("dmpf:psndatas:info")
    public Result info(@PathVariable("id") Integer id)
    {
        PsndatasEntity psndatas = psndatasService.getById(id);
        
        return Result.ok().put("psndatas", psndatas);
    }
    
    /**
     * 保存
     */
    @MyDoneTime(param = "PsndatasController.save")
    @RequestMapping("/save")
    @RequiresPermissions("dmpf:psndatas:save")
    public Result save(@RequestBody PsndatasEntity psndatas)
    {
        psndatasService.save(psndatas);
        
        return Result.ok();
    }
    
    /**
     * 修改
     */
    @MyDoneTime(param = "PsndatasController.update")
    @RequestMapping("/update")
    @RequiresPermissions("dmpf:psndatas:update")
    public Result update(@RequestBody PsndatasEntity psndatas)
    {
        psndatasService.updateById(psndatas);
        
        return Result.ok();
    }
    
    /**
     * 删除
     */
    @MyDoneTime(param = "PsndatasController.list")
    @RequestMapping("/delete")
    @RequiresPermissions("dmpf:psndatas:delete")
    public Result delete(@RequestBody Integer[] ids)
    {
        psndatasService.removeByIds(Arrays.asList(ids));
        
        return Result.ok();
    }
    
}
